{% extends "admin/models/base_filters.html" %}

{% block tab_index_class %}active{% endblock %}

<!-- extra_tabs start -->
{% block extra_tabs %}
    <li class="dropdown" style="float:right">
      <a class="dropdown-toggle" data-toggle="dropdown" href="#">操作... <span class="caret" /></a>
      <ul class="dropdown-menu pull-right">
      	{% if 'export' not in model_admin.method_exclude %}
        <li><a href="#" onclick="Admin.index_submit('export');">导出</a></li>
		{% endif %}
		{% if 'delete' not in model_admin.method_exclude %}
        <li><a href="#" onclick="Admin.index_submit('delete');">删除</a></li>
		{% endif %}
		{% for op in model_admin.object_op %}
			{% set key=op.__class__.__name__ %}
		 <li><a href="#" onclick="Admin.index_submit('{{ key }}');">{{ op.verbose_name }}</a></li>
		{% endfor %}
      </ul>
    </li>
    {% include "admin/includes/filter_dropdown.html" %}
{% endblock %}
<!-- extra_tabs end -->


{% block content %}

  {% include "admin/includes/filter_widgets.html" %}
  
  <!-- table & form start -->
  <form action="." class="form-horizontal" id="model-list" method="post"><input type="hidden" name="action" value="" />
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th class="check first shrink"><input type="checkbox" name="xxx" onchange="javascript:$('td input[type=checkbox]').attr('checked', this.checked);" /></th>
        {% if model_admin.columns or model_admin.show_all_columns %}
          {% for column in model_admin.columns or model_admin.get_columns() if column %}
            {% if ordering == column %}
              {% set sort_by = '-'+column %}
            {% else %}
              {% set sort_by = column %}
            {% endif %}
            <th>{% if model_admin.column_is_sortable(column) %}<a href="./?{{ update_querystring(request.query_string, 'ordering', sort_by)|safe() }}">{% endif %}{{ model_admin.get_column_display(column) }}{% if model_admin.column_is_sortable(column) %}</a>{% endif %}</th>
          {% endfor %}
        {% else %}
          <th>{{ model_admin.get_display_name() }}</th>
        {% endif %}
		{% if model_admin.get_primary_key() or model_admin.object_op %}
        <th class="last shrink"></th>
		{% endif %}
      </tr>
    </thead>
    <tbody>
    {% for object in query.get_list() %}
      <tr>
        <td class="check"><input type="checkbox" name="id" value="{{ object.get_id() }}" /></td>
        {% if model_admin.columns or model_admin.show_all_columns %}
          {% for column in model_admin.columns or model_admin.get_columns() if column %}
            {% if loop.index == 1 %}
			  {% if model_admin.get_primary_key() %}
              <td><a href="{% if 'edit' not in model_admin.method_exclude %}{{ url_for(model_admin.get_url_name('edit'), pk=object.get_id()) }}{% else %}#{% endif %}">{{ get_model_field(object, column) }}</a></td>
			  {% else %}
			  <td>{{ get_model_field(object, column)|string|truncate(length=55, killwords=True, end='...') }}</td>
			  {% endif %}
            {% else %}
              <td>{{ get_model_field(object, column)|string|truncate(length=55, killwords=True, end='...') }}</td>
            {% endif %}
          {% endfor %}
        {% else %}
          <td><a href="{% if 'edit' not in model_admin.method_exclude %}{{ url_for(model_admin.get_url_name('edit'), pk=object.get_id()) }}{% else %}#{% endif %}">{{ object }}</a></td>
        {% endif %}
		{% if model_admin.get_primary_key() or model_admin.object_op %}
        <td class="last links">
          <ul class="inline">
          	{% if 'edit' not in model_admin.method_exclude %}
            <li><a href="{{ url_for(model_admin.get_url_name('edit'), pk=object.get_id()) }}">编辑</a></li>
			{% endif %}
			{% if 'delete' not in model_admin.method_exclude %}
            <li><a href="{{ url_for(model_admin.get_url_name('delete'), id=object.get_id()) }}">删除</a></li>
			{% endif %}
			{% for op in model_admin.object_op %}
				{% set key=op.__class__.__name__ %}
				{% if op.pk %}
			<li><a href="{{ url_for(model_admin.get_url_name(key), id=get_model_field(object, op.pk) ) }}">{{ op.verbose_name }}</a></li>
				{% else %}
			 <li><a href="{{ url_for(model_admin.get_url_name(key), id=object.get_id()) }}">{{ op.verbose_name }}</a></li>
			 	{% endif %}
			{% endfor %}
          </ul>
        </td>
		{% endif %}
      </tr>
    {% endfor %}
    </tbody>
  </table>
  </form>
  <!-- table & form end -->
  
  {% include "admin/includes/pagination.html" %}
  
{% endblock %}
